<h1>Accueil</h1>
<div class="cadreContenu">
	<?php 
	if (file_exists('pages/connexion.php')){
		require_once ('pages/connexion.php');
	}else{
		require_once ('../connexion.php');
	}
	// Selection de l'id de la page accueil
	try{
		$sql = 'SELECT id FROM pages WHERE titre=:accueil';
		$select = $connection->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
		$select->execute(array(':accueil' => 'Accueil'));
		$enregistrement = $select->fetch(PDO::FETCH_OBJ);
	
		if($enregistrement==true){
			//Selection des parties de la page
			
			$sql2 = 'SELECT * FROM partie WHERE idPages=:idPages ORDER BY ordre';
			$select2 = $connection->prepare($sql2, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
			$select2->execute(array(':idPages' => $enregistrement->id ));
			while( $enregistrement2 = $select2->fetch(PDO::FETCH_OBJ) )
				{?>
					<h1><?php echo $enregistrement2->titre;?></h1>
					<?php 
						if ($enregistrement2->idImages!=null){
							$sql3 = 'SELECT * FROM images WHERE id=:idImages';
							$select3 = $connection->prepare($sql3, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
							$select3->execute(array(':idImages' => $enregistrement2->idImages ));
							$enregistrement3 = $select3->fetch(PDO::FETCH_OBJ);
							
							if($enregistrement3){?>
							<div class="imgCenter">
								<div class="imgCenter2"><img id="imgBIG" src="images/<?php echo $enregistrement3->chemin;?>"/></div>
							</div>
							<?php
							}
						}
					?>
					
					<p><?php echo $enregistrement2->contenu;?></p>
				<?php
				}
		}
	}catch(Exception $e){
		echo "<h3 class='error'>Impossible de charger la page accueil</h3>";
	}
							
	?>
</div>



